<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title></title>
    <style>
        .container {
            height: 85%;
            width: 97%;
            position: fixed;
            overflow-x: auto;
            overflow-y: scroll;
        }

        .btn-hide {
            display: none;
        }

        * {
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 业务数据管理 <span
        class="c-gray en">&gt;</span> 历史数据查询 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                                 href="javascript: f_getinfo(); " title="刷新">
    <i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container" style="padding-top: 0">
    <div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-top: 0">
        <span class="l">
            <label><input type="text" class="input-text" style="width:250px" placeholder="选择查询月份" id="inputSearch" name=""></label>
            <a href="javascript:" onclick="f_add()" class="btn btn-primary radius" id="add"><i class="Hui-iconfont">&#xe600;</i> 查询记录</a>
        </span>
    </div>
    <div class="container">
        <table style="table-layout:fixed; width: 10px; word-break:break-all;" class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="tablelist">
            <thead>
            <tr class="text-c">
                <th style="display: none">系统编号</th>
                <th style="width: 45px;">编号</th>
                <th style="width: 95px; background:#e2efda">母卷规格</th>
                <th style="width: 65px;  background:#e2efda">客户</th>
                <th style="width: 80px; background:#e2efda">规格</th>
                <th style="width: 50px;  background:#e2efda">孔型</th>
                <th style="width: 80px; background:#e2efda">下月预计量</th>
                <th style="width: 70px; background:#e2efda">管芯</th>
                <th style="width: 80px; background:#e2efda">纸箱</th>
                <th style="width: 110px; background:#e2efda">发货时间</th>
                <th style="width: 70px; background:#ddebf7">母卷需求</th>
                <th style="width: 70px; background:#ddebf7">管芯需求</th>
                <th style="width: 70px; background:#ddebf7">纸箱需求</th>
                <th style="width: 150px; background:#ddebf7">生产时间安排</th>
                <th style="width: 60px; background:#ddebf7">机台</th>
                <th style="width: 100px; background:#ddebf7">操作者</th>
                <th style="width: 100px; background:#ddebf7">生产计划/已完成</th>
                <th style="width: 80px; background:#ddebf7">生产未完成</th>
                <th></th>
            </tr>
            </thead>
            <tbody id="datalist">
            </tbody>
        </table>

    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="lib/laydate/laydate.js"></script>
<script type="text/javascript">

    let is_right = "0";
    let ii_page = 1;   //--上一页下一页的计数器
    let ii_row = 20;   //--每页显示的记录数
    let ii_count = 0;
    let is_dangyue = "";  //--当前所选择的月份
    let is_max = "";

    $(document).ajaxComplete(function (event, xhr, settings) {
        //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
        if (xhr.getResponseHeader("sessionstatus") === "timeout") {
            //从http头信息取出登录的url ＝ loginPath
            if (xhr.getResponseHeader("loginPath")) {
                window.location.replace(xhr.getResponseHeader("loginPath"));
            }
        }
    });

    $(document).ready(function () {
        f_init();

        laydate.render({
            elem: '#inputSearch',
            type:'month',
            format: 'yyyy-MM',
            max : is_max,
            btns: ['clear', 'confirm']
        });
    });

    function f_init() {
        var ls_opid = "${sessionOpid}";
        $.ajax({
            type: 'post',
            url: 'com',
            data: {
                CMD: 'BH',
                VALUE01: ls_opid
            },
            async: false,
            success: function (data) {
                let jsonobj = JSON.parse(data);

                let json1 = jsonobj.db1;
                is_max = json1[0].VALUE01.toString();
            },
            error: function () {
                layer.msg('网络异常错误', {icon: 1, time: 1000});
            }
        })
    }

    function f_getinfo() {
        let ls_opid = "${sessionOpid}";
        if (!ls_opid) {
            layer.msg("请重新登录系统！", {icon: 0, time: 1000});
            return;
        }

        ii = 1;
        $.ajax({
            type: 'post',
            url: 'com',
            data: {
                URL: '',
                CMD: 'AJ',
                VALUE01: ls_opid,
                VALUE02: is_dangyue
            },
            async: false,
            success: function (data) {
                var jsonobj = JSON.parse(data);

                let c_table = $("#datalist");
                c_table.html("");
                let str = "";
                let json1 = jsonobj.db1;
                let li_count = Object.keys(json1).length;
                let li_num = 1;
                for (let key in json1) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json1[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE07.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE08.toString() + "</td>" +
                            "<td style='background:#e2efda; ' >" + json1[key].VALUE09.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE10.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE11.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE12.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE13.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE14.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE15.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE16.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE17.toString() + "</td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json1[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE07.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE08.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE09.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE10.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE11.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE12.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE13.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE14.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE15.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE16.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE17.toString() + "</td>" +
                            "</tr>";
                    }
                    ii++;
                }

                //------------遍历第二张表，库管表
                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                str += "<tr class='text-c'>" +
                    "<td >" + parseInt(ii) + "</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>规格</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>孔型</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>成品库存</td>" +
                    "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                    "</tr>"
                ii++;

                let json2 = jsonobj.db2;
                li_count = Object.keys(json2).length;
                li_num = 1;
                for (let key in json2) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json2[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json2[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json2[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json2[key].VALUE04.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json2[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json2[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json2[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold' >" + json2[key].VALUE04.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                    }
                    ii++;
                }

                //------------遍历第三张表 采购表
                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                str += "<tr class='text-c'>" +
                    "<td >" + parseInt(ii) + "</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>母卷规格</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>母卷库存量</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>月度总需求</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>已采购</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>预计到货日期</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>缺口</td>" +
                    "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                    "</tr>"
                ii++;

                let json3 = jsonobj.db3;
                li_count = Object.keys(json3).length;
                li_num = 1;
                for (let key in json3) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json3[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json3[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE07.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json3[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold'>" + json3[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json3[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE07.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                    }
                    ii++;
                }

                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                c_table.html(str);
            },
            error: function () {
                layer.msg('网络异常错误', {icon: 1, time: 1000});
            }
        })
    }

    /*增加一笔记录*/
    function f_add() {
        is_dangyue = $("#inputSearch").val();
        if (is_dangyue.length === 0) {
            layer.msg('请先选择月份!', {icon: 0, time: 2000});
            return;
        }

        f_getinfo();
    }

</script>
</body>
</html>
